#define  _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<unordered_map>
using namespace std;
int globalVar = 1;
static int staticGlobalVar = 1;
void Test()
{
	static int staticVar = 1;
	int localVar = 1;
	int num1[10] = { 1, 2, 3, 4 };
	char char2[] = "abcd";
	const char* pChar3 = "abcd";
	char2[1] = 'a';
	cout << char2;
	int* ptr1 = (int*)malloc(sizeof(int) * 4);
	int* ptr2 = (int*)calloc(4, sizeof(int));
	int* ptr3 = (int*)realloc(ptr2, sizeof(int) * 4);
	free(ptr1);
	free(ptr3);
}
unordered_map<char, int> a;
unordered_map<char, int> b;
bool checkAlmostEquivalent(string word1, string word2) {
    for (char i = 'a'; i <= 'z'; i++)
    {
        a.insert({ i,0 });
        b.insert({ i,0 });

    }
    for (char e : word1)
    {
        a[e]++;
    }
    for (char e : word2)
        b[e]++;
    auto it = b.begin();
    for (auto e1 : a)
    {
       
        if (abs(e1.second - it->second) > 3)
        {
            //cout << abs(e1.second - it->second) << endl;
            return false;
        }
        it++;
    }
    return true;
}
int main()
{

    if (checkAlmostEquivalent("aaaa", "aaaa"))
    {
        cout << "YES" << endl;
    }
	return 0;
}